package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.Result;
import com.bwie.vo.LoginVo;
import com.bwie.vo.MobileVo;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/index")
public class IndexController {

    @Autowired
    TbUserService tbUserService;


    /**
     * 账号密码登录
     *
     * @return
     */
    @PostMapping("/accountLogin")
    public Result accountLogin(@RequestBody @Validated LoginVo loginVo) {
        return tbUserService.accountLogin(loginVo);
    }

    /**
     * 发送验证码
     * @return
     */
    @PostMapping("/sendCode/{mobile}")
    public Result sendCode(@PathVariable("mobile") String mobile) {
        return tbUserService.sendCode(mobile);
    }


    /**
     * 手机号登录
     * * @param loginVo
     *
     * @return
     */
    @PostMapping("/mobileLogin")
    public Result mobileLogin(@RequestBody @Validated MobileVo mobileVo) {
        return tbUserService.mobileLogin(mobileVo);
    }

    /**
     * 根据用户ID获取用户的菜单树
     *
     * @param
     * @return
     */
    @PostMapping("/getMenuTree")
    public Result getMenuTree() {
        return tbUserService.getMenuTree();
    }

    /**
     * 用户列表
     *
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getUserList")
    public Result getUserList(@RequestBody PageInfoVo pageInfoVo) {
        return tbUserService.getUserList(pageInfoVo);
    }
}
